import http from "/@/utils/http";

// 接口类型和方法
interface BaseType{
    postList(data: object, url: string, headers?: object):any;
}

class PostRequest implements BaseType{
    postList = (data: object, url: string, headers?: object) =>{
        if (typeof headers == "undefined" || headers == null) {
            return http.request({
                url: url,
                method: 'POST',
                data
            })
        } else {
            return http.request({
                url: url,
                headers,
                method: 'POST',
                data
            })
        }
    }
    postUrlEncode = (data: string, url: string, headers: object) =>{
        return http.request({
            url: url,
            headers,
            method: 'POST',
            data
        })
    }

    postFile = (data: FormData, url: string, headers: object) =>{
        return http.request({
            url: url,
            headers,
            method: 'POST',
            data
        })
    }
}

const post = new PostRequest()


export default post;